<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <!-- TopJUI框架样式 -->
    <link type="text/css" href="../../topjui/themes/default/topjui.core.min.css" rel="stylesheet">
    <link type="text/css" href="../../topjui/themes/default/topjui.blue.css" rel="stylesheet" id="dynamicTheme"/>
    <!-- FontAwesome字体图标 -->
    <link type="text/css" href="../../static/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- layui框架样式 -->
    <link type="text/css" href="../../static/plugins/layui/css/layui.css" rel="stylesheet"/>
    <!-- jQuery相关引用 -->
    <script type="text/javascript" src="../../static/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="../../static/plugins/jquery/jquery.cookie.js"></script>
    <!-- TopJUI框架配置 -->
    <script type="text/javascript" src="../../static/public/js/topjui.config.js"></script>
    <!-- TopJUI框架核心-->
    <script type="text/javascript" src="../../topjui/js/topjui.core.min.js"></script>
    <!-- TopJUI中文支持 -->
    <script type="text/javascript" src="../../topjui/js/locale/topjui.lang.zh_CN.js"></script>
    <!-- layui框架js -->
    <script type="text/javascript" src="../../static/plugins/layui/layui.js" charset="utf-8"></script>
    <style>
        .dp{
            opacity:0.5;
            filter:alpha(opacity=50);
            border: 1px solid gainsboro;
            padding: 4px;
        }
        .over{
            background:#FBEC88;
        }
    </style>
</head>

<body>
    <div style="float: left;width:400px;height: 500px;margin: 10px;border: 1px solid lavender">
        <div class="topjui-fluid">
            <fieldset>
                <legend>拖动组件，放置在右侧面板</legend>
            </fieldset>
            <div class="topjui-row" >
                <div class="topjui-col-sm12">
                    <div id="textbox">
                        <label class="topjui-form-label">文本框</label>
                        <div class="topjui-input-block product">
                            <input type="text" name="name" data-toggle="topjui-textbox" data-options="prompt:'这是一个文本框'">
                        </div>
                    </div>
                </div>
            </div>
            <div class="topjui-row">
                <div class="topjui-col-sm12">
                    <div id="passwordbox">
                        <label class="topjui-form-label">密码框</label>
                        <div class="topjui-input-block">
                            <input type="text" name="passwordbox" data-toggle="topjui-passwordbox" data-options="prompt:'这是一个密码框组件'">
                        </div>
                    </div>
                </div>
            </div>
            <div class="topjui-row">
                <div class="topjui-col-sm12">
                    <div id="combobox">
                        <label class="topjui-form-label">下拉列表框</label>
                        <div class="topjui-input-block">
                            <input type="text" name="nation"
                                   data-toggle="topjui-combobox"
                                   data-options=" prompt:'这是一个下拉列表框' ">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="dd" style="float: left;width: 400px;height: 500px;border: 1px solid lavender;margin: 10px;overflow-y: auto;">
        <div class="topjui-fluid" >
            <fieldset>
                <legend>放置这里</legend>
            </fieldset>
        </div>
    </div>
    <p> </p>
    <script>
      $('#dd').iDroppable({
        accept:'#textbox,#passwordbox,#combobox',
        onDrop:function(e,source){
          $(this).removeClass('over');
          var newElem =$(source).clone();
          newElem.removeAttr('id')
          $(newElem).appendTo(this);
          $(newElem).css("margin","0 0 10px 0")
        },
        onDragEnter:function(e,source){
          $(this).addClass('over');
        },
        onDragLeave:function (e,source) {
          $(this).removeClass('over');
        }
      });
      $('#textbox').iDraggable({
        proxy:'clone',
        revert:true,
        onStartDrag:function(){
          $(this).draggable('proxy').addClass('dp');
        }
      });
      $('#passwordbox').iDraggable({
        proxy:'clone',
        revert:true,
        onStartDrag:function(){
          $(this).draggable('proxy').addClass('dp');
        }
      });
      $('#combobox').iDraggable({
        proxy:'clone',
        revert:true,
        onStartDrag:function(){
          $(this).draggable('proxy').addClass('dp');
        }
      });

    </script>
</body>

</html>
